﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanoAula.Core.Helper
{
    public static class Helper
    {
        public static void ExbirFormulario(this FormEdicao destino, Form origem)
        {
            destino.WindowState = FormWindowState.Maximized;
            destino.StartPosition = FormStartPosition.CenterParent;

            if (origem.MdiParent != null)
            {
                var formulario = (from f in origem.MdiParent.MdiChildren
                                  where f.Name == destino.Name
                                  select f).FirstOrDefault();

                if (formulario != null)
                {
                    formulario.Activate();
                }
                else
                {
                    destino.MdiParent = origem.MdiParent;
                    destino.Show();
                }
            }
            else
            {
                destino.MdiParent = origem;
                destino.Show();
            }

        }
    }
}
